<?php

namespace App\Observers;
use Carbon\Carbon;

class OrderObserver {
	
    public function saving($model)
    {
    	if ($model->actualed_at && is_numeric($model->year)) {

    		// 续费年限
    		$renewYear = $model->renews ? $model->renews->sum('year') : 0;
    		
    		$model->expired_at = $model->actualed_at->addYears($model->year + $renewYear)->endOfDay();
    	}
    }

}